package cn.sunxyz.enums;

import java.util.function.Supplier;

/**
 * Created by yangrd on 2017/5/27.
 */
public enum SizeSingletonEnum {
    SMALL(new ISize() {
        @Override
        public void size() {
            System.out.println("小号");
        }
    }), MEDIUM(() ->
            System.out.println("中号")
    ), LARGE(((Supplier<ISize>) (LargeSize::new)).get()), DEFAULT(new SizeImpl());

    SizeSingletonEnum(ISize size) {
        this.size = size;
    }

    private ISize size;

    public ISize getISize() {
        return size;
    }

    static class LargeSize implements ISize{
        
        {
            System.out.println("CREATE LARGE");
        }

        @Override
        public void size() {
            System.out.println("大号");
        }
    }
}
